home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 3: Developer Tools / Linux Cubed Series 3 - Developer Tools.iso / devel / db / esm-3.1 / esm-3 / usr / local / sm / src / include / ess.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-05-05  |  7.0 KB  |  317 lines

  1. #ifndef _ESS_H_
  2. #define _ESS_H_
  3. #ifndef __ESS_H__
  4. #define __ESS_H__
  5.  
  6. /*
  7.  *   $RCSfile: ess.h,v $  
  8.  *   $Revision: 1.1.1.1 $  
  9.  *   $Date: 1996/05/04 21:55:08 $
  10.  */ 
  11.  
  12.  
  13. /**********************************************************************
  14. * EXODUS Database Toolkit Software
  15. * Copyright (c) 1991 Computer Sciences Department, University of
  16. *                    Wisconsin -- Madison
  17. * All Rights Reserved.
  18. *
  19. * Permission to use, copy, modify and distribute this software and its
  20. * documentation is hereby granted, provided that both the copyright
  21. * notice and this permission notice appear in all copies of the
  22. * software, derivative works or modified versions, and any portions
  23. * thereof, and that both notices appear in supporting documentation.
  24. *
  25. * THE COMPUTER SCIENCES DEPARTMENT OF THE UNIVERSITY OF WISCONSIN --
  26. * MADISON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" CONDITION.  
  27. * THE DEPARTMENT DISCLAIMS ANY LIABILITY OF ANY KIND FOR ANY DAMAGES
  28. * WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
  29. *
  30. * The EXODUS Project Group requests users of this software to return 
  31. * any improvements or extensions that they make to:
  32. *
  33. *   EXODUS Project Group 
  34. *     c/o David J. DeWitt and Michael J. Carey
  35. *   Computer Sciences Department
  36. *   University of Wisconsin -- Madison
  37. *   Madison, WI 53706
  38. *
  39. *     or exodus@cs.wisc.edu
  40. *
  41. * In addition, the EXODUS Project Group requests that users grant the 
  42. * Computer Sciences Department rights to redistribute these changes.
  43. **********************************************************************/
  44.  
  45. /*
  46.  * ess.h
  47.  * defines, typedefs, etc. used by all of ess.
  48.  */
  49.  
  50. /* BEGIN visible to user */
  51.  
  52. /*
  53.  *    Turn on function prototypes for these compilers
  54.  */
  55. #if defined(_AIX) || defined(mips) || defined(__cplusplus) || defined(c_plusplus) || defined(__GNUC__)
  56. #    define PROTO(_parms) _parms 
  57. #else
  58.     /*
  59.      *    Turn it off for everything else
  60.      */
  61. #    define PROTO(_parms) ()
  62. #endif
  63.  
  64. #ifdef __cplusplus
  65. #define BEGIN_EXTERNC extern "C" {
  66. #define END_EXTERNC }
  67. #else
  68. #define BEGIN_EXTERNC 
  69. #define END_EXTERNC 
  70. #endif __cplusplus
  71.  
  72. /*
  73.  * Allow things to compile with c and c++ without having to 
  74.  * ifdef-out each use of "const"
  75.  */
  76. #ifndef __cplusplus
  77. #define const
  78. #endif
  79.  
  80. /*
  81.  * Some compilers do not know about volatile, including ATT C++.
  82.  * G++ seems to know about it.
  83.  * In order to avoid all sorts of warnings about the use
  84.  * of volatile in places like <sys/smp_lock.h> (for ultrix),
  85.  * and serverlib/include/queues.h.o, we define volatile out of
  86.  * existence for ATT C++.
  87.  */
  88. #if defined(__cplusplus) && !defined(__GNUC__)
  89. #define volatile
  90. #endif
  91.  
  92.  
  93. /*
  94.  * Boolean values.
  95.  */
  96. typedef char BOOL;
  97.  
  98. #ifndef TRUE
  99. #define TRUE    (1)
  100. #endif
  101. #ifndef FALSE
  102. #define FALSE    (0)
  103. #endif
  104.  
  105. /*
  106.  *    define some values for general macro expansion
  107.  */
  108. #define IS_ENABLED        ==1)
  109. #define IS_DISABLED        ==0)
  110. #define ENABLED            (1
  111. #define DISABLED        (0
  112.  
  113. /*
  114.  *    Universal constant for flags field
  115.  */
  116. #define NOFLAGS            ((FLAGS) 0)
  117.  
  118.  
  119. /*
  120.  * Machine dependent constants.
  121.  */
  122. #define    BYTESPERWORD    (sizeof(int))
  123. #ifndef BITSPERBYTE
  124. #    define    BITSPERBYTE        8
  125. #endif
  126. #define    BITSPERWORD        (BITSPERBYTE * BYTESPERWORD)
  127.  
  128.  
  129. /*
  130.  * Special "no error" error return.
  131.  */
  132. #define    esmNOERROR    0        /* non-error "error" code    */
  133. #define esmFAILURE    -1        /* standard failure call    */
  134.  
  135.  
  136. /*
  137.  * Invalid pointer values.
  138.  */
  139. #ifndef NULL
  140. #define    NULL        (VOID *)0    /* invalid memory address. Don't use this for int types; use ZERO */
  141. #endif
  142.  
  143. #define    ZERO        0
  144.  
  145. #define    NIL            -1        /* invalid integer index */
  146.  
  147.  
  148. /*
  149.  * Typedefs used all over.
  150.  */
  151. typedef char    ONE;            /* 1 byte */
  152. typedef short    TWO;            /* 2 bytes */
  153. typedef long    FOUR;            /* 4 bytes */
  154.  
  155.  
  156. typedef void    (*PFV)();        /* pointer to void function        */
  157. typedef int        (*PFI)();        /* pointer to integer function        */
  158. typedef char    *(*PFCP)();        /* pointer to char pointer function */
  159.  
  160. typedef unsigned char    UONE;    /* 1 byte */
  161. typedef unsigned short    UTWO;    /* 2 bytes */
  162. typedef unsigned long    UFOUR;    /* 4 bytes */
  163.  
  164. #ifndef _AIX
  165. typedef unsigned long    ulong;
  166. #endif
  167.  
  168. typedef unsigned int    FLAGS;
  169. typedef unsigned long    MAGIC;
  170. typedef unsigned short    SHORT_MAGIC;
  171.  
  172. /*
  173.  * These typedefs go here because they are used all over the place.
  174.  * They are variants of flags but are given different types to
  175.  * help avoid conflicts.
  176.  */
  177. typedef    FLAGS    BFFLAGS;
  178. typedef    FLAGS    SCANFLAGS;
  179. typedef    FLAGS    SCANTYPE;
  180. typedef    FLAGS    NEIGHBORFLAGS;
  181.  
  182.  
  183. /*
  184.  * Version history graph node id.
  185.  */
  186. typedef FOUR VHGNODEID;
  187.  
  188. /*
  189.  *  define a type for a slotted page slot
  190.  */
  191. typedef TWO     SLOTINDEX;
  192.  
  193. /*
  194.  * Macro for checking errors.
  195.  */
  196. #define    CHECKERROR(a)                             \
  197.         if ((int)(a) < smNOERROR) return ((int)(a))
  198.  
  199. /* END visible to user */
  200.  
  201. /*
  202.  * Macros for comparisions.
  203.  */
  204. #ifndef MIN
  205. #define    MIN(x,y)                            \
  206.         ((x) < (y) ? (x) : (y))
  207. #endif  MIN
  208.  
  209. #ifndef MAX
  210. #define    MAX(x,y)                            \
  211.         ((x) > (y) ? (x) : (y))
  212. #endif  MAX
  213.  
  214. #ifndef ABS
  215. #define    ABS(x)                            \
  216.         ((x) > 0 ? (x) : (-x))
  217. #endif     ABS
  218.  
  219.  
  220. /* BEGIN visible to user */
  221.  
  222. /*
  223.  *    Set object alignment to 8 byte bountries.
  224.  *
  225.  *    The only valid values are 8 and 4.  Adding new values
  226.  *    requires a change to include/object.h.
  227.  */
  228. #define ALIGNON 8
  229. #define ALIGNON1 (ALIGNON-1)
  230.  
  231. /*
  232.  *    the object size align macro
  233.  *
  234.  *    This macro aligns object sizes to ALIGNON boundries.
  235.  *    Note that zero length objects are also rounded up.
  236.  */
  237. #define ALIGNSIZE(_size)                                \
  238.     ( ((_size) == 0) ? ALIGNON :( (_size) + ALIGNON1 ) & ~ALIGNON1)
  239.  
  240.  
  241. /* END visible to user */
  242.  
  243. /*
  244.  *    the align macro for general power of two alignment
  245.  */
  246. #define ALIGN(_value, _target)                        \
  247.                                                         \
  248.     (((_value) + ((_target) - 1)) & (~((_target) - 1)))
  249.  
  250. /*
  251.  * The following kludge is simply so that we can tell which
  252.  * .o files were compiled with debug and which without (by using nm(1)).
  253.  * Both of these chars are defined in libcommon.a
  254.  */
  255. #ifdef DEBUG
  256. extern char debug_is_on;
  257. #else DEBUG
  258. extern char debug_is_off;
  259. #endif DEBUG
  260.  
  261. typedef struct hostent        HOSTENT;
  262. typedef struct sockaddr_in    SOCKADDR;
  263. typedef struct servent        SERVENT;
  264. typedef struct timeval        TIMEVAL;
  265.  
  266. /*
  267.  *    SM_FREE_PTR is to be used instead of free().
  268.  *  GET should be used wherever it works.
  269.  */
  270. #define SM_FREE_PTR(_ptr)         \
  271.     if ((_ptr) != NULL) {         \
  272.         free((char*)(_ptr));    \
  273.         (_ptr) = NULL;             \
  274.     }
  275.  
  276. #define GET(result, TYPE, amount) \
  277.     if ((result = (TYPE *) malloc(sizeof(TYPE)*amount)) == NULL)    {\
  278.         SM_ERROR(TYPE_SYS, esmMALLOCFAILED);\
  279.         return esmFAILURE;\
  280.     }
  281.  
  282.  
  283. /* Macro for handling errors:
  284.  * Each function has a label FailureReturn, where the 
  285.  * failure case is treated: malloc-ed stuff is 
  286.  * freed, pages are unfixed,  and esmFAILURE is returned.
  287.  */
  288. #ifdef DEBUG
  289.  
  290. static int                FailureLineNumber; /* uninitialized */
  291. #define     FAIL        FailureLineNumber = __LINE__; goto FailureReturn;
  292.  
  293. BEGIN_EXTERNC
  294.     int FakeFailure(int);
  295. END_EXTERNC
  296. /* for testing only */
  297. #define FAKEFAIL(e) if(FakeFailure(e)) { return esmFAILURE; }
  298.  
  299. #else
  300.  
  301. #define     FAIL        goto FailureReturn;
  302. #define     FAKEFAIL(x) 
  303.  
  304. #endif DEBUG
  305.  
  306. /* brain-damaged cfront can't handle anything but trivial inline funcs, so 
  307.  * we'll just make none of these things inline for cfront.
  308.  */
  309. #if defined(__GNUC__) && !defined(DEBUG)
  310. #define INLINE inline
  311. #else
  312. #define INLINE 
  313. #endif
  314.  
  315. #endif /* __ESS_H__ */
  316. #endif /* _ESS_H_ */
  317.